package com.epidata.exam.model;

import java.util.Set;
import java.util.TreeSet;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlSeeAlso;

@Table
@Entity
@XmlRootElement
@XmlSeeAlso(ReciboDeSueldo.class)
public class Employee extends Person {
	/** Default value included to remove warning. Remove or modify at will. **/
	private static final long serialVersionUID = 1L;


	public Employee() {
		super();
		recibos = new TreeSet<ReciboDeSueldo>();
	}

	public Employee(Long id, String name, String phoneNumber, String email,
			Set<ReciboDeSueldo> recibos) {
		super(id, name, phoneNumber, email);
		this.recibos = recibos;
	}


	@OneToMany(mappedBy = "owner",cascade = {CascadeType.ALL},fetch = FetchType.EAGER)
	private Set<ReciboDeSueldo> recibos;

	@XmlElement(name = "recibosDeSueldo")
	public Set<ReciboDeSueldo> getRecibos() {
		return recibos;
	}

	public void setRecibos(Set<ReciboDeSueldo> recibos) {
		this.recibos = recibos;
	}

	public void addRecibo(ReciboDeSueldo recibo) {
		recibo.setOwner(this);
		this.recibos.add(recibo);
	}

}